package vns.server.domain;


import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import vns.shared.ObjectTypeDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class ObjectType {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;
	@Persistent()
	private Set<Key> reportcolumn;
	@Persistent()
	private Set<Key> object;
	@Persistent
	private String name;
	@Persistent
	private boolean isuser;
	@Persistent
	private boolean isPicklist;
	@Persistent
	private String describe;
	
	public ObjectType(ObjectTypeDTO objectTypeDTO){
		this.name=objectTypeDTO.getName();
		this.isuser=objectTypeDTO.getIsuser();
		this.describe=objectTypeDTO.getDescribe();
		this.isPicklist = objectTypeDTO.getPicklist();
	}
	
	public void updatefromDTO(ObjectTypeDTO objectTypeDTO){
		this.name=objectTypeDTO.getName();
		this.isuser=objectTypeDTO.getIsuser();
		this.describe=objectTypeDTO.getDescribe();
		this.isPicklist = objectTypeDTO.getPicklist();
	}
	
	public ObjectTypeDTO toDTO(){
		ObjectTypeDTO objectTypeDTO=new ObjectTypeDTO(this.id,this.name,
				this.isuser, this.isPicklist,this.describe);
		return objectTypeDTO;
	}
	
	public Key getId(){
		return id;
	}
	
	public Set<Key> getReportColumn(){
		return reportcolumn;
	}
	
	public void addReportColumn(Key report){
		this.reportcolumn.add(report);
	}
	
	public void removeReportColumn(Key ReportColumn){
		this.reportcolumn.remove(ReportColumn);
	}
		
	public Set<Key> getObject(){
		return object;
	}
	public void addObject(Key _object){
		this.object.add(_object);
	}
	
	public void removeObject(Key Object){
		this.object.remove(Object);
	}
	
	public String getName(){
		return name;
	}
	
	public void setName(String Name){
		this.name=Name;
	}
	
	public boolean getIsuser(){
		return isuser;
	}
	
	public void setIsuser(boolean Isuser){
		this.isuser=Isuser;
	}
	
	public String getDescribe(){
		return describe;
	}
	
	public void setDescribe(String Describe){
		this.describe=Describe;
	}

	public void setPicklist(boolean isPicklist) {
		this.isPicklist = isPicklist;
	}

	public boolean getPicklist() {
		return isPicklist;
	}
}
